import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter_local/base/BaseItemPage.dart';
import 'package:flutter_local/ext/Route.dart';
import 'package:flutter_local/ui/HttpPage.dart';
import 'package:flutter_local/ui/ImagePage.dart';
import 'package:flutter_local/ui/Page2.dart';
import 'package:flutter_local/ui/WalletPage.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:svgaplayer_flutter/player.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends BaseItemPage {
  MyHomePage({super.key});

  @override
  List<Widget> getItems() {
    return <Widget>[
      addItemWidget("跳转页面", () {
        goPage(context, const Page2());
      }),
      addItemWidget("本地轻量级存储", () async {
        var sp = await SharedPreferences.getInstance();
        var aaa1 = await sp.setBool("aaa", true);
        var aaa2 = sp.get("aaa");
        log("$aaa1,$aaa2");
      }),
      addItemWidget("图片加载", () {
        goPage(context, ImagePage());
      }),
      addItemWidget("网络请求", () {
        goPage(context, HttpPage());
      }),
      addItemWidget("svga播放(本地)", () {
        showMyDialog(const SVGASimpleImage(assetsName: "svga/timing.svga"));
      }),
      addItemWidget("svga播放(网络)", () {
        showMyDialog(const SVGASimpleImage(
            resUrl: "http://static.scmingrizhixing.cn/guzhang.svga"));
      }),
      addItemWidget("ETH钱包相关", () {
        goPage(context, WalletPage());
      })
    ];
  }
}
